﻿using UnityEngine;
using System.Collections;

public class MapEditorPanellPen : MonoBehaviour
{
    public Collision CollisionInfo;
    void Start()
    {
        Rigidbody body =  gameObject.AddComponent<Rigidbody>();
        body.useGravity = false;
        body.freezeRotation =true;
        ScaleColliderSize();
    }

    void ScaleColliderSize()
    {
        BoxCollider boxCollider = gameObject.GetComponent<BoxCollider>();
        if (boxCollider != null)
        {
            boxCollider.size =new Vector3(boxCollider.size.x-0.01f, boxCollider.size.y - 0.01f, boxCollider.size.z - 0.01f);
        }
    }


    public void SetMousePos(Vector3 mousePos)
    {
        transform.localPosition = mousePos;
    }

    public void OnCollisionStay(Collision collision)
    {
        for(int i=0;i< collision.contacts.Length;i++)
        {
            //ContactPoint cp = collision.contacts[i];
            
        }
        CollisionInfo = collision;
    }

    public void OnCollisionExit(Collision collision)
    {
        CollisionInfo = null;
    }
}
